﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Win32;
using System.Windows;

namespace eipch
{
    class GlobalSettings
    {
        private static Templates _Templates;
        private String _XMLTemplatesPath;
        private static bool _flag_XML_Loaded = false;

        private NetworkManagement _networkManagement;

        public GlobalSettings()
        {
            //Objekt instanzieren
            _XMLTemplatesPath = String.Format("{0}Templates.xml", System.AppDomain.CurrentDomain.BaseDirectory);
            _networkManagement = new NetworkManagement();
            this.init();
        }

        public void init()
        {
            if (_Templates == null) _Templates = new Templates();
            if (!_flag_XML_Loaded) this.LoadTemplateXML();
        }

        public NetworkManagement getNetworkManagement()
        {
            return _networkManagement;
        }

        public void LoadTemplateXML()
        {
            if (System.IO.File.Exists(_XMLTemplatesPath))
            {
                _Templates.Load(_XMLTemplatesPath);
                _flag_XML_Loaded = true;
            }
        }

        /// <summary>
        /// Speichert die Templates
        /// </summary>
        public void SaveTemplateXML()
        {
            _Templates.Save(_XMLTemplatesPath);
        }

        public Templates templates()
        {
            return _Templates;
        }
    }
}
